package gui;

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class JanelaBaskaraSwing extends JFrame implements ActionListener {
    private JButton btCalcular;
    private JTextField tfA,tfB,tfC;
    private JLabel lbResultX1,lbResultX2;
    
    private Container container;
    
    public JanelaBaskaraSwing(){
        super("Fórmula de Baskara");
        
        
        container = this.getContentPane();
        
        container.setLayout(new FlowLayout());
        
        btCalcular = new JButton("Calcular");
        tfA = new JTextField(10);
        tfB = new JTextField(10);
        tfC = new JTextField(10);
        lbResultX1 = new JLabel("0.0");
        lbResultX2 = new JLabel("0.0");
        
        container.add(new JLabel("A:"));
        container.add(tfA);
        container.add(new JLabel("B:"));
        container.add(tfB);
        container.add(new JLabel("C:"));
        container.add(tfC);
        container.add(btCalcular);
        container.add(new JLabel("X':"));
        container.add(lbResultX1);
        container.add(new JLabel("X'':"));
        container.add(lbResultX2);
        
        container.setBackground(Color.green);
        
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        btCalcular.addActionListener(this);
        
        this.setSize(640, 480);
        this.setVisible(true);
    }
   
    public static void main(String[] args) {
        
        JanelaBaskaraSwing jb = new JanelaBaskaraSwing();
        
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        container.setBackground(Color.blue);
    }
}
